package com.study.d027shape2d;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.StrokeLineJoin;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;

/** 多条线段
*@description
*@author xtayhame
*date 2020年3月21日
*version
*since v1.0
*/
public class PolyLineMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		VBox box = new VBox(10);

		//多条线段1
		Polyline p1 = new Polyline(0,0,100,0, 200,50);
		p1.setStroke(Paint.valueOf("#8B4513"));

		//带闭合的线段
		ObservableList<Double> dobs=FXCollections.observableArrayList();
		dobs.addAll(0.0, 0.0, 100.0, 0.0, 100.0, 100.0, 0.0, 0.0);
		Polyline p2 = new Polyline();
		p2.getPoints().addAll(dobs);


		//字母Z
		ObservableList<Double> dobs3=FXCollections.observableArrayList();
		dobs3.addAll(0.0, 0.0, 100.0, 0.0,  0.0,100.0, 100.0,100.0);
		Polyline p3 = new Polyline();
		p3.getPoints().addAll(dobs3);

		//设置线段衔接处平滑
		p3.setStrokeLineCap(StrokeLineCap.ROUND);
		p3.setStrokeLineJoin(StrokeLineJoin.ROUND);

		//
		ObservableList<Double> dobs4=FXCollections.observableArrayList();
		dobs4.addAll(0.0, 0.0, 100.0, 0.0,  0.0,100.0, 100.0,100.0, 0.0 ,0.0);
		Polyline p4 = new Polyline();
		p4.getPoints().addAll(dobs4);
		p4.setFill(Paint.valueOf("#8B4513"));

		box.getChildren().addAll(p1,p2,p3,p4);
		anchorPane.getChildren().add(box);
		AnchorPane.setTopAnchor(box, 30.0);
		stage.setScene(new Scene(anchorPane, 800, 500));
		stage.show();
	}
}
